<script>
     methods: {
        handleSubmit(formInline) {
            this.$refs[formInline].validate((valid) => {
                if (valid) {
                    if (this.formInline.password.length < 6) {
                        this.$Message.error('密码不不少于6位数!');
                    }
                    this.$http

                    this.postHttp("/token", JSON.stringify(this.formInline))
                        .then(response => {
                            let data = response.body;
                            if (data.code === "0") {
                                this.$Message.success('登录成功!');
                                router.go("/home")
                            } else {
                               this.$Message.error('密码不正确!');
                            }
                        }, (error) => {
                            console.log(error);
                        })

                } else {
                    this.$Message.error('登录失败!');
                }
            })
        }
    }




     //第一次请求封装
                            this.$http({
                                method:'GET',
                                url:'http://192.168.10.124:8080/oauth/token?v=1_13',
                                async: false,
                               // data:{v:"1_13"},
                                //headers: {"X-Requested-With": "XMLHttpRequest"},
                                emulateJSON: true
                              }).then(response => {
                                let data = response.body;
                                let userkey = data.Data.Token
                                console.log(userkey);


                                //第二次请求封装  (已经成功) //注意事项：data必须是json
                                //
                            this.$http({
                                method:'POST',
                                url:'http://192.168.10.124:8080/oauth/pubkey?v=1_13',
                                async: false,
                                data:JSON.stringify({token:userkey},
                                //headers: {"X-Requested-With": "XMLHttpRequest"},
                                emulateJSON: true
                              }).then(response => {
                                let data = response.body;
                                    let pubkey = data.Data.Pubkey
                                console.log(pubkey);



                            this.postHttp("/pubkey?v=1_13",JSON.stringify({token:userkey}))
                                .then(response => {
                                    let data = response.body;
                                    let pubkey = data.Data.Pubkey
                                    console.log(pubkey);

                                    //准备第三次请求 (psot方式)
                                    //获取帐号、密码、Token、pubkey
                                   let userBy = this.formInline.user;
                                   let passWord = this.formInline.password;
                                   // let token = userkey;
                                   // let publickey = pubkey;
                                this.postHttp("/login?v=1_13",JSON.stringify({
                                    PassWord:passWord,
                                    LoginBy:userBy,
                                    Token:userkey,
                                    PublicKey:pubkey
                                }))
                                    .then(response => {
                                        alert("11")
                                        let data = response.body;
                                        //let pubkey = data.Data.Pubkey
                                        console.log(data);
                                }, (error) => {
                                    console.log(error)
                                })
// {"PassWord":"99ff093331b03897","LoginBy":"admin","Token":"7a57536d-1c63-j499-wc0e-5126d595a9c3","PublicKey":"29750e58"}
                                    //第三次请求结束

                                }, (error) => {
                                    console.log(error)
                                })
                                 //第二次请求结束  (已经成功)

                            }, (error) => {
                                console.log(error)
                            })
                            //第一次请求结束  (已经成功)
</script>